﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace OPCTreeMonitor.SQLdb.Infrastructure
{
    public interface IRepository<TEntity> where TEntity : class, new()
    {
        #region 查询操作
        TEntity GetById(object id);
        List<TEntity> GetAll();
        List<TEntity> Where(Expression<Func<TEntity, bool>> expression);
        #endregion

        #region 增删改操作
        bool Insert(TEntity entity);
        bool Update(TEntity entity);
        bool Delete(TEntity entity);
        #endregion

        #region 批量操作
        int InsertRange(List<TEntity> entities);
        int UpdateRange(List<TEntity> entities);
        int DeleteRange(List<TEntity> entities);
        #endregion

        #region 异步操作
        Task<TEntity> GetByIdAsync(object id);
        Task<List<TEntity>> GetAllAsync();
        Task<int> InsertAsync(TEntity entity);
        Task<int> UpdateAsync(TEntity entity);
        Task<int> DeleteAsync(TEntity entity);
        #endregion


        #region 扩展修改方法
        bool Update(TEntity entity, Expression<Func<TEntity, object>> columns);
        #endregion

      

        // 添加获取SQL Sugar客户端的方法
        SqlSugarClient GetDbClient();
    }
}
